//
//  UIBarButtonItem+item.m
//  Catus
//
//  Created by 晓梦影 on 16/4/25.
//  Copyright © 2016年 黄金星. All rights reserved.
//

#import "UIBarButtonItem+item.h"

@implementation UIBarButtonItem (item)

+ (instancetype)itemWith:(UIImage *)image addTarget:(nullable id)target action:(SEL)action
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    btn.frame = CGRectMake(0, 0, 30, 30);
    // 设置按钮的整体内容移动
//    btn.contentEdgeInsets = UIEdgeInsetsMake(10, 10, -10, -10);
//    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView *containView = [[UIView alloc]initWithFrame:btn.bounds];
    [containView addSubview:btn];
    return [[UIBarButtonItem alloc]initWithCustomView:containView];
}
@end
